package com.ruoyi.web.controller.tool;

import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;


@Component//依赖注入框架
public class RedisTool {
    public Jedis getJedis() {
        Jedis jedis = null;
        try {
            jedis = new Jedis("114.116.69.142", 6379);//设置连接地址
            jedis.auth("080234");//设置密码
            jedis.select(0);//选择数据库
            System.out.println("连接成功!");
        } catch (Exception e) {
            System.out.println("连接失败" + e.getMessage());
        } finally {
            if (jedis != null) {
                try {
                    jedis.close();
                } catch (Exception e) {
                    System.out.println("关闭失败" + e.getMessage());
                }
            }
        }
        return jedis;
    }

}
